import request from "@/utils/request";

//添加项目
export function addProjectApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("name", data.name);
    formData.append("domains", data.domains);
    formData.append("targetWord", data.targetWord);
    formData.append("Introduction", data.Introduction);
    return request({
        url: "/GEOBasicApi/AddProject",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//获取项目
export function getProjectApi(): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/AddProjectView",
        method: "get",
    });
}

//获取项目前置+后置关键词
export function getProjectKeywordApi(url:string): Promise<ResType> {
    return request({
        url: url + "/AddKeywordsView",
        method: "get",
    });
}

//添加项目关键词
export function addProjectKeywordApi(url:string,data: any): Promise<ResType> {
    return request({
        url: url + "/AddKeywords",
        method: "post",
        data: data,
        headers: {
            "Content-Type": "application/json",
        },
    });
}

//获取关键词列表
export function getKeywordListApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/KeywordList",
        method: "get",
        params: Params,
    });
}

//获取关键词报表
export function getKeywordReportApi(url:string,Params: any): Promise<ResType> {
    return request({
        url: url,
        method: "get",
        params: Params,
    });
}

//获取类关键词数据
export function getSimilarKeywordApi(url:string,Params: any): Promise<ResType> {
    return request({
        url: url,
        method: "get",
        params: Params,
    });
}

//获取问答数据
export function getQuestionDataApi(url:string,Params?: any): Promise<ResType> {
    return request({
        url: url,
        method: "get",
        params: Params,
    });
}

//获取平台问题
export function getPlatformQuestionApi(url:string,Params?: any): Promise<ResType> {
    return request({
        url: url,
        method: "get",
        params: Params,
    });
}

//获取问题排名
export function getQuestionRankApi(Params?: any): Promise<ResType> {
    return request({
        url: "/GEOBasicCustomerApi/GetKeywordRanking",
        method: "get",
        params: Params,
    });
}

//导出问题表
export function exportKeywordApi(url:string,data: any): Promise<ResType> {
    return request({
        url: url + "/KeywordsExport",
        method: "post",
        data: data,
        headers: {
            "Content-Type": "application/json",
        },
    });
}

//导入问题表
export function importKeywordApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("Keyword", data.Keyword);
    formData.append("Title", data.Title);
    return request({
        url: "/GEOBasicApi/KeywordsImport",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//历史排名 - 每次排名
export function getHistoryRankApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/HistoricalRanking",
        method: "get",
        params: Params,
    });
}

//历史排名 - 每月排名
export function getMonthRankApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/HistoricalRankingMonth",
        method: "get",
        params: Params,
    })
}

//生成文章
export function createArticleApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("ID", data.ID);
    formData.append("count", data.count);
    formData.append("oneclick", data.oneclick);
    return request({
        url: "/GEOBasicApi/CreateArticleTask",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//获取文章列表
export function getArticleListApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/GetArticleList",
        method: "get",
        params: Params,
    });
}

//获取文章详细
export function getArticleDetailApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/GetArticleDetail",
        method: "get",
        params: Params,
    });
}

//修改文章
export function editArticleApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("ID", data.ID);
    formData.append("ArticleContent", data.ArticleContent);
    return request({
        url: "/GEOBasicApi/EditArticle",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//拼接词
export function combineWordsApi(url:string,data: any): Promise<ResType> {
    return request({
        url: url + "/Keyword_CombinationList",
        method: "post",
        data: data,
        headers: {
            "Content-Type": "application/json",
        },
    });
}

//发布文章
export function publishArticleApi(data: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/CreatePublishTask",
        method: "post",
        data: data,
        headers: {
            "Content-Type": "application/json",
        },
    });
}

//批量发布文章
export function batchPublishArticleApi(data: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/CreateBatchPublishTask",
        method: "post",
        data: data,
        headers: {
            "Content-Type": "application/json",
        },
    });
}

//文章发布统计
export function getArticleStatisticsApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/GetArticleTask",
        method: "get",
        params: Params,
    });
}

//发布技术文章
export function publishTechArticleApi(data: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/CreateBatchSiteWebTask",
        method: "post",
        data: data,
        headers: {
            "Content-Type": "application/json",
        },
    });
}

//查看技术文章
export function getTechArticleApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/GetArticleSiteWebTask",
        method: "get",
        params: Params,
    });
}

//获取词介绍列表
export function getDistillationIntroApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/GetWordData",
        method: "get",
        params: Params,
    });
}

//词介绍详细
export function getDistillationIntroDetailApi(Params: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/GetWordByID",
        method: "get",
        params: Params,
    });
}

//新增/编辑词介绍
export function addDistillationIntroApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("ID", data.ID);
    formData.append("Introduction", data.Introduction);
    return request({
        url: "/GEOBasicApi/AddWordIntroduction",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//删除文章
export function deleteArticleApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("id", data.id);
    return request({
        url: "/GEOBasicApi/DeleteArticle",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//批量设置文章数
export function batchSetArticleNumApi(data: any): Promise<ResType> {
    return request({
        url: "/GEOBasicApi/CreateArticleTask",
        method: "post",
        data: data,
    });
}

//查看组合词
export function getCombinationWordsApi(url:string,Params: any): Promise<ResType> {
    return request({
        url: url + "/SelectComposeByID",
        method: "get",
        params: Params,
    });
}

//查看问题预览
export function getQuestionPreviewApi(url:string,data: any): Promise<ResType> {
    return request({
        url: url + "/Keyword_CombinationList",
        method: "post",
        data: data,
    });
}

//提交问题组合词
export function submitCombinationApi(url:string,data: any): Promise<ResType> {
    return request({
        url: url + "/AddCompoundWords",
        method: "post",
        data: data,
    });
}